#include "NameScreen.h"
#include "ContentScreen.h"
#include <MultiWidgets\TextWidget.hpp>
#include <MultiWidgets\KeyboardWidget.hpp>
#include <MultiWidgets\TextEditWidget.hpp>
#include <MultiWidgets\TextWidget.hpp>
void NameScreen::nextScreen(){
	Radiant::BinaryData data;
	//data.write(temp);
	eventSend("nextScreen",data);
}

void NameScreen::init(){

	setBackgroundColor(0,0,0,1);

	



	auto kb = MultiWidgets::create<MultiWidgets::KeyboardWidget>();
	kb -> setFont(QFont("Helvetica", 12));
	kb->timerDial()->removeFromParent();
	kb->setScale(1.2);
	kb->setBackgroundColor(1,1,1,.1);
	kb->setCenterLocation(Nimble::Vector2(width()/2,50 +height()/2+kb->height()/2));
	kb->setFixed();
	addChild(kb);


	auto nameBox = MultiWidgets::create<MultiWidgets::TextEditWidget>();
	nameBox->setKeyboard(kb);
	nameBox->setSize(kb->width()/14*9, kb->height()/3);
	nameBox->setScale(1.2);
	nameBox-> setLocation(kb->x(), height()/2 - nameBox->height()/2 - 100   );
	nameBox->setInputFlags(INPUT_NONE);
	addChild(nameBox);

	auto b1 = MultiWidgets::create<MultiWidgets::TextWidget>("next");
	b1->setInputFlags(INPUT_SINGLE_TAPS);
	b1->setSize(kb->width()/7*2, kb->height()/3);
	b1->setScale(1.2);
	b1-> setLocation(kb->x() +( kb->width()*1.2)-(b1->width()*1.2), height()/2 - b1->height()/2 - 100   );
    b1->eventAddListener("single-tap", "nextStart", this);
	addChild(b1);

	auto textbox = MultiWidgets::create<MultiWidgets::TextWidget>("Enter your name");
	textbox->setInputFlags(INPUT_NONE);
	textbox->setSize(kb->width(), kb->height()/3);
	textbox->setScale(1.2);
	textbox-> setLocation(kb->x(), height()/3 - nameBox->height()/2 - 100   );
	addChild(textbox);
}

 void NameScreen::eventProcess(const QByteArray & messageId, Radiant::BinaryData & data)
  {
    if(messageId == "nextStart") nextScreen();

  }